# Init
AC_INIT([SocketServer], [0.4], [onteria@live.jp], [SocketServer])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.10 -Wall no-define])

# Check Programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_CHECK_PROG([ICU_CONFIG], [icu-config], [icu-config])


# Check Libraries
AC_CHECK_LIB([miko], [miko_create_socket], [MIKO_LIB=-lmiko], [AC_MSG_ERROR([Failed to find libmiko utility functions.])])
AC_CHECK_LIB([pthread], [pthread_exit], [PTHREAD_LIB=-lpthread],  [AC_MSG_ERROR([Failed to find pthread threading library.])])
AC_CHECK_LIB([confuse], [cfg_parse], [CONFUSE_LIB=-lconfuse],  [AC_MSG_ERROR([Failed to find libconfuse config library.])])
AC_CHECK_LIB([icuuc], [main], [ICU_LDFLAGS=[`icu-config --ldflags --ldflags-icuio`]], [AC_MSG_ERROR([ICU library not installed.])])

# Check Headers
AC_CHECK_HEADERS([miko/miko.h miko/socket.h])
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([confuse.h])
AC_CHECK_HEADERS([unicode/ustring.h], [ICU_CFLAGS=[`icu-config --cflags`]])

# Substitute variables
AC_SUBST([MIKO_LIB])
AC_SUBST([PTHREAD_LIB])
AC_SUBST([CONFUSE_LIB])
AC_SUBST([ICU_LDFLAGS])
AC_SUBST([ICU_CFLAGS])

# Output Files
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
